home *** CD-ROM | disk | FTP | other *** search
/ Enter 2001 April / EnterCD4.iso / Grafika / Flying PopCorn 2001 / Data.Cab / F12073_System.js < prev    next >
Encoding:
Text File  |  2000-08-20  |  3.2 KB  |  168 lines

  1. var gnPixelInterval = 50;
  2. var gnTimeInterval = 500;
  3. var gnViewBoardWidth = 640;
  4. var gnViewBoardHeight= 480;
  5. var    oList = new Array();
  6.  
  7.  
  8.  
  9. function GetCoord( divID, direction )
  10. {
  11.     if (navigator.appName == 'Netscape') 
  12.           {
  13.           if( direction == "left" )
  14.               return divID.left;
  15.  
  16.         if( direction == "top" )
  17.               return divID.left;
  18.           }
  19.     else
  20.           {
  21.           if( direction == "left" )
  22.               return divID.style.pixelLeft;
  23.  
  24.         if( direction == "top" )
  25.               return divID.style.pixelTop;
  26.         }  
  27. }
  28.  
  29.  
  30.  
  31.  
  32. function SetCoord( divID, x, y)
  33. {
  34.  
  35.     if (navigator.appName == 'Netscape') 
  36.         {
  37.         divID.left = x;
  38.         divID.top  = y;
  39.         }
  40.     else 
  41.         {
  42.         divID.style.pixelLeft = x;
  43.         divID.style.pixelTop  = y;
  44.         }
  45.  
  46. }
  47.  
  48.  
  49.  
  50. function ShowObject( divID, bFlag ) {
  51.     if (navigator.appName == 'Netscape') 
  52.         {
  53.         divID.visibility = bFlag ? 'show': 'hide'
  54.         } 
  55.     else
  56.         {
  57.         divID.style.visibility = bFlag ? 'visible' : 'hidden' ;
  58.         }
  59. }
  60.  
  61.  
  62.   
  63. function create_object(name, direct) 
  64. {
  65.     var str = (navigator.appName == 'Netscape') ? 'document.'+name : 'document.all[\''+name+'\']';
  66.     var object;
  67.     
  68.     object          = eval(str);
  69.     object.name        = name;
  70.     object.mleft    = 0;
  71.     object.mtop        = 0;
  72.     object.oleft    = GetCoord( object, "left" );
  73.     object.otop        = GetCoord( object, "top" );
  74.     object.direct    = direct;
  75.  
  76.     // transfer position
  77.     if( direct == "r2l" )
  78.         object.mleft    = gnViewBoardWidth;
  79.     else if( direct == "d2u" )
  80.         object.mtop    = gnViewBoardHeight;
  81.  
  82.     ShowObject( object, false );
  83.     
  84.     return object;
  85. }
  86.  
  87.  
  88. function funcSetMainBoard( divID )
  89. {
  90. //    var x = (screen.availWidth  - gnViewBoardWidth )/2;
  91. //    var y = (screen.availHeight - gnViewBoardHeight)/2;
  92.     var x = 0;
  93.     var y = 0;
  94.     
  95.     SetCoord( divID, x, y );
  96.     ShowObject( divID, true );
  97. }
  98.  
  99.  
  100. function funcMove( idx )
  101. {
  102.     var myObj = oList[idx];
  103.  
  104.  
  105.     // Show Object 
  106.     if( myObj.direct == "r2l" || myObj.direct == "l2r" )
  107.         {
  108.         SetCoord( myObj, myObj.mleft, GetCoord(myObj, "top") );
  109.         }
  110.     else if( myObj.direct == "d2u" || myObj.direct == "u2d" )
  111.         {
  112.         SetCoord( myObj, GetCoord(myObj, "left"), myObj.mtop  );
  113.         }
  114.  
  115.     ShowObject( myObj, true );
  116.  
  117.  
  118.  
  119.  
  120.  
  121.     if( myObj.direct == "l2r" )
  122.         {
  123.         if( myObj.mleft < myObj.oleft  )
  124.             {
  125.             myObj.mleft += gnPixelInterval;
  126.             if( myObj.mleft + gnPixelInterval > myObj.oleft )
  127.                 myObj.mleft =  myObj.oleft;
  128.             setTimeout( "funcMove("+ idx +")", gnTimeInterval);
  129.             }
  130.         }
  131.     else if( myObj.direct == "r2l" )
  132.         {
  133.         if( myObj.mleft > myObj.oleft  )
  134.             {
  135.             myObj.mleft -= gnPixelInterval;
  136.             if( myObj.mleft - gnPixelInterval < myObj.oleft )
  137.                 myObj.mleft = myObj.oleft;
  138.             setTimeout( "funcMove("+ idx +")", gnTimeInterval);
  139.             }
  140.         }
  141.     else if( myObj.direct == "u2d" )
  142.         {
  143.         if( myObj.mtop < myObj.otop  )
  144.             {
  145.             myObj.mtop += gnPixelInterval;
  146.             if( myObj.mtop + gnPixelInterval > myObj.otop )
  147.                 myObj.mtop = myObj.otop;
  148.                 
  149.             setTimeout( "funcMove("+ idx +")", gnTimeInterval);
  150.             }
  151.         }
  152.     else if( myObj.direct == "d2u" )
  153.         {
  154.         if( myObj.mtop > myObj.otop  )
  155.             {
  156.             myObj.mtop -= gnPixelInterval;
  157.             if( myObj.mtop - gnPixelInterval < myObj.otop )
  158.                 myObj.mtop = myObj.otop;
  159.             setTimeout( "funcMove("+ idx +")", gnTimeInterval);
  160.             }
  161.         }
  162.  
  163.     else     // if( myObj.direct == "none" )
  164.         {
  165.         return ;
  166.         }
  167.         
  168. }